/**
 * ------------------------------------------------------------*
 *          COPYRIGHT (C) 2006 BOCO Inter-Telecom INC          *
 *   CONFIDENTIAL AND PROPRIETARY. ALL RIGHTS RESERVED.        *
 *                                                             *
 *  This work contains confidential business information       *
 *  and intellectual property of BOCO  Inc, Beijing, CN.       *
 *  All rights reserved.                                       *
 * ------------------------------------------------------------*
 *
 /**
  *Revision Information:
  *
  *@version 1.0 2006-5-23 release(liheng)
  */

package com.boco.webmaster.system.callboard.action;

import javax.servlet.http.HttpServletRequest;
import com.boco.transnms.client.model.base.IBoCommand;
import com.boco.transnms.client.model.base.BoCmdFactory;
import com.boco.transnms.server.bo.helper.cm.CallBoardBOHelper;
import com.boco.transnms.common.dto.base.BoActionContext;
import com.boco.transnms.common.dto.base.DataObjectList;
import com.boco.webmaster.base.SessionManager;
import com.boco.transnms.common.dto.CallBoard;
import java.util.Date;
import java.text.SimpleDateFormat;
import com.boco.common.util.lang.TimeFormatHelper;

public class JspCallBoardHelper {
    public static class AttrName {

    }

    public static void initCallBoardRows(HttpServletRequest request){
        StringBuffer callBoards = new StringBuffer("");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String currentDate = sdf.format(new Date());
        IBoCommand cmd = BoCmdFactory.getInstance().createBoCmd(CallBoardBOHelper.ActionName.getCallBoardByCondition, new Object[] {new BoActionContext(),currentDate});
        DataObjectList dbos = ((DataObjectList)cmd.exec());
        for(int i=0; i<dbos.size(); i++){
            callBoards.append("<a href=\"/webmaster/system/callboard/callBoardText.jsp?objectId="+ ((CallBoard)dbos.get(i)).getObjectId() +"\" target=\"_blank\"><font style=\"font-size: 12px\">");
            callBoards.append(((CallBoard)dbos.get(i)).getInfotitle());
            callBoards.append("</font></a><br><br>");
        }
        SessionManager.getInstance().saveQueryAttr(request, "callBoards", callBoards.toString());
    }

    public static String[] initCallBoardText(String objectId){
        String[] arr = new String[4];
        IBoCommand cmd = BoCmdFactory.getInstance().createBoCmd(CallBoardBOHelper.ActionName.getCallBoard, new Object[] {new BoActionContext(),Long.parseLong(objectId)});
        CallBoard callBoard = (CallBoard)cmd.exec();
        arr[0] = callBoard.getInfotitle();
        arr[1] = "&nbsp;&nbsp;&nbsp;&nbsp;" + callBoard.getInfotext();
        arr[2] = callBoard.getAuthor();
        arr[3] =  TimeFormatHelper.getFormatDate(callBoard.getBegindatetime(),TimeFormatHelper.TIME_FORMAT_A);

        return arr;

    }

}
